//
//  AY_BookDayCell.m
//  AiYue
//
//  Created by boWen on 2023/10/17.
//

#import "AY_BookDayCell.h"
@interface AY_BookDayCell ()

/** 书 */
@property (strong,nonatomic) UIImageView *bookImage;

/** 书名 */
@property (strong,nonatomic) UILabel *desLabel;

@property (strong,nonatomic) UILabel *tipLabel;
@property (strong,nonatomic) UILabel *authorLabel;

@end

@implementation AY_BookDayCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.bookImage = [AYTool createImageViewWithFrame:CGRectZero andImage:nil andBg:nil andRadius:YNUM(4) andAddSubView:self.contentView];
        [self.bookImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(YNUM(93));
            make.top.left.right.equalTo(self.contentView);
        }];
        
        self.tipLabel = [AYTool createLabelWithFrame:CGRectZero andText:nil andTextColor:[UIColor whiteColor] andBgColor:nil andFont:YFont(10) andLines:1 andRadius:0 andAddSubView:self.bookImage];
        self.tipLabel.layer.masksToBounds = NO;
        self.tipLabel.textAlignment = NSTextAlignmentCenter;
        [self.tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.top.equalTo(self.bookImage);
            make.width.mas_equalTo(YNUM(28));
            make.height.mas_equalTo(YNUM(16));
        }];
        
        UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, YNUM(28), YNUM(16)) byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(YNUM(4), YNUM(4))];
        CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
        maskLayer.frame = self.tipLabel.bounds;
        maskLayer.path = maskPath.CGPath;
        self.tipLabel.layer.mask = maskLayer;
    
        self.desLabel = [AYTool createLabelWithFrame:CGRectZero andText:nil andTextColor:COLOR(@"#010101") andBgColor:nil andFont:YFont(14) andLines:2 andRadius:0 andAddSubView:self.contentView];
        [self.desLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.bookImage.mas_bottom).offset(YNUM(5));
            make.left.right.equalTo(self.bookImage);
        }];
        
        self.authorLabel = [AYTool createLabelWithFrame:CGRectZero andText:nil andTextColor:COLOR(@"#bfbfbf") andBgColor:nil andFont:YFont(12) andLines:1 andRadius:0 andAddSubView:self.contentView];
        [self.authorLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.desLabel.mas_bottom).offset(YNUM(5));
            make.left.right.equalTo(self.bookImage);
        }];
    }
    return self;
}


- (void)setSubModel:(BookDecModel *)subModel {
    _subModel = subModel;
    [self.bookImage sd_setImageWithURL:[NSURL URLWithString:kStringUtils(_subModel.imagePic)] placeholderImage:YImage(@"placeholderImage")];
//    self.authorLabel.text = subModel.author;
    self.desLabel.text = kStringUtils(_subModel.name);
    [AYTool setBookStatusWithStatus:_subModel.status andLabel:self.tipLabel];
}




@end
